<!DOCTYPE HTML>
<html>
<head>

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>详情</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/css/uploadifive.css">
    <link type="text/css" rel="stylesheet" href="/js/plugins/layer/laydate/skins/default/laydate.css" id="LayDateSkin">


</head>
<body>
<h2>{{if .update}}更新{{else}}添加{{end}}</h2>
<!--style给定宽度可以影响编辑器的最终宽度-->

<!--style给定宽度可以影响编辑器的最终宽度-->
<form id="FORM_validate" action="/devices/{{if .update}}update{{else}}add{{end}}" method="post">
    <input id="form_Id" type="hidden" value="{{if .update}}{{.Devices.Id}}{{end}}" name="{{if .update}}Id{{end}}">
    <div class="">
    	<div class="form-group col-md-12">
            <label class="col-md-3 control-label">设备名称：</label>
            <div class="col-md-9">
                <input id="form_DeviceName" name="DeviceName" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DeviceName}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">SN码：</label>
            <div class="col-md-9">
                <input id="form_DeviceSN" name="DeviceSN" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DeviceSN}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">设备类型：</label>
            <div class="col-md-9">
                <select class="form-control m-b" name="DeviceType">
                    <option {{if .update}}{{if eq 1 .Devices.DeviceType}}selected="selected"{{end}}{{else}}{{if eq 1 .Type}}selected="selected"{{end}}{{end}} value="1">烟雾传感器</option>
                    <option {{if .update}}{{if eq 2 .Devices.DeviceType}}selected="selected"{{end}}{{else}}{{if eq 2 .Type}}selected="selected"{{end}}{{end}} value="2">可燃气</option>
                    <option {{if .update}}{{if eq 3 .Devices.DeviceType}}selected="selected"{{end}}{{else}}{{if eq 3 .Type}}selected="selected"{{end}}{{end}} value="3">热成像</option>
                    <option {{if .update}}{{if eq 4 .Devices.DeviceType}}selected="selected"{{end}}{{else}}{{if eq 4 .Type}}selected="selected"{{end}}{{end}} value="4">节点电压</option>
                    <option {{if .update}}{{if eq 5 .Devices.DeviceType}}selected="selected"{{end}}{{else}}{{if eq 5 .Type}}selected="selected"{{end}}{{end}} value="5">温度监控</option>
                    <option {{if .update}}{{if eq 6 .Devices.DeviceType}}selected="selected"{{end}}{{else}}{{if eq 6 .Type}}selected="selected"{{end}}{{end}} value="6">消防用水</option>
                    <option {{if .update}}{{if eq 7 .Devices.DeviceType}}selected="selected"{{end}}{{else}}{{if eq 7 .Type}}selected="selected"{{end}}{{end}} value="7">边界入侵</option>
                </select>
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">设备状态：</label>
            <div class="col-md-9">
                <select class="form-control m-b" name="DeviceStatus">
                    <option {{if .update}}{{if eq 0 .Devices.DeviceStatus}}selected="selected"{{end}}{{end}} value="0">初始化</option>
                    <option {{if .update}}{{if eq 1 .Devices.DeviceStatus}}selected="selected"{{end}}{{end}} value="1">正常运行</option>
                    <option {{if .update}}{{if eq 2 .Devices.DeviceStatus}}selected="selected"{{end}}{{end}} value="2">维修检测</option>
                    <option {{if .update}}{{if eq 3 .Devices.DeviceStatus}}selected="selected"{{end}}{{end}} value="3">故障</option>
                </select>
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">topic：</label>
            <div class="col-md-9">
                <input id="form_DeviceTopic" name="DeviceTopic" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DeviceTopic}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">创建时间：</label>
            <div class="col-md-9">
                <input placeholder="YYYY-MM-DD hh:mm:ss" name="devicecreatetime"
                       value="{{if .update}}{{date .Devices.DeviceCreateTime "Y-m-d H:i:s"}}{{end}}"
                       onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
                       class="laydate-icon form-control layer-date"
                       required="" aria-required="true">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">更新时间：</label>
            <div class="col-md-9">
                <input placeholder="YYYY-MM-DD hh:mm:ss" name="deviceupdatetime"
                       value="{{if .update}}{{date .Devices.DeviceUpdateTime "Y-m-d H:i:s"}}{{end}}"
                       onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
                       class="laydate-icon form-control layer-date"
                       required="" aria-required="true">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">authName：</label>
            <div class="col-md-9">
                <input id="form_DeviceAuthName" name="DeviceAuthName" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DeviceAuthName}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">authPass：</label>
            <div class="col-md-9">
                <input id="form_DeviceAuthPass" name="DeviceAuthPass" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DeviceAuthPass}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">地点：</label>
            <div class="col-md-9">
                <input id="form_DevicePosition" name="DevicePosition" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DevicePosition}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">纬度：</label>
            <div class="col-md-9">
                <input id="form_DeviceLatitude" name="DeviceLatitude" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DeviceLatitude}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">经度：</label>
            <div class="col-md-9">
                <input id="form_DeviceLongtitude" name="DeviceLongtitude" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DeviceLongtitude}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">报警值（分号分割，低程度报警在前，高程度在后）：</label>
            <div class="col-md-9">
                <input id="form_AlarmValues" name="AlarmValues" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.AlarmValues}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">数据单位：</label>
            <div class="col-md-9">
                <input id="form_DataUnit" name="DataUnit" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.DataUnit}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">微信预警推送等级，默认为1：</label>
            <div class="col-md-9">
                <input id="form_WXPushGrade" name="WXPushGrade" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.WXPushGrade}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">微信预警推送时间间隔,以分钟为单位：</label>
            <div class="col-md-9">
                <input id="form_WXPushInterval" name="WXPushInterval" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.WXPushInterval}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">短信预警推送等级，默认为2：</label>
            <div class="col-md-9">
                <input id="form_MessagePushGrade" name="MessagePushGrade" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.MessagePushGrade}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">短信预警推送时间间隔,以分钟为单位：</label>
            <div class="col-md-9">
                <input id="form_MessagePushInterval" name="MessagePushInterval" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.MessagePushInterval}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">电话预警推送等级,默认为3：</label>
            <div class="col-md-9">
                <input id="form_CallPushGrade" name="CallPushGrade" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.CallPushGrade}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">电话预警推送时间间隔,以分钟为单位：</label>
            <div class="col-md-9">
                <input id="form_CallPushInterval" name="CallPushInterval" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.CallPushInterval}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <div class="col-md-3">
            	<label class="control-label">设备图片：</label>
                <input id="form_DevicePic" type="hidden" name="DevicePic" value="{{if .update}}{{.Devices.DevicePic}}{{end}}" required="" aria-required="true">
                <button id="file_upload_DevicePic" name="file_upload_DevicePic" type="file" multiple="true"></button>
            </div>
            <div class="col-md-9">
                <img id="form_pic_DevicePic" src="{{if .update}}{{.Devices.DevicePic}}{{else}}/img/image.png{{end}}"
                     style="max-height: 380px;width: auto;">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">设备用户Id：</label>
            <div class="col-md-9">
                <input id="form_User" name="User" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Devices.User}}{{end}}">
            </div>
        </div>
		
    	<div class="form-group col-md-12">
            <div class="col-md-12 col-md-offset-3">
                <button class="btn btn-primary" type="submit">保存内容</button>
                {{if .update}}{{else}}
                <button class="btn btn-white" type="submit">取消</button>
                {{end}}
            </div>
        </div>
    </div>
</form>



<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/jquery.uploadifive.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="/js/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/js/ueditor.all.min.js"></script>
<script type="text/javascript" src="/lang/zh-cn/zh-cn.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>


<!-- jQuery UI -->
<script src="/js/jquery-ui-1.10.4.min.js"></script>
<!-- laydate js -->
<script src="/js/plugins/layer/laydate/laydate.js"></script>

<!--form validate-->
<script>
    $().ready(function () {
        // validate the comment form when it is submitted
        $("#FORM_validate").validate({
            rules: {
                DeviceName:{
                    required:true,
                    minlength: 2
                },
                DeviceSN:{
                    required:true,
                    minlength: 2
                },
                DeviceTopic:{
                    required:true,
                    minlength: 2
                },
                DeviceAuthName:{
                    required:true,
                    minlength: 2
                },
                DeviceAuthPass:{
                    required:true,
                    minlength: 2
                },
                DevicePosition:{
                    required:true,
                    minlength: 2
                },
                DeviceLatitude:{
                    required:true,
                    numbers:true
                },
                DeviceLongtitude:{
                    required:true,
                    numbers:true
                },
                AlarmValues:{
                    required:true,
                    minlength: 2
                },
                DataUnit:{
                    required:true,
                    minlength: 1
                },
                WXPushGrade:{
                    required:true,
                    digits:true
                },
                WXPushInterval:{
                    required:true,
                    digits:true
                },
                MessagePushGrade:{
                    required:true,
                    digits:true
                },
                MessagePushInterval:{
                    required:true,
                    digits:true
                },
                CallPushGrade:{
                    required:true,
                    digits:true
                },
                CallPushInterval:{
                    required:true,
                    digits:true
                },
                User:{
                    required:true,
                    digits:true
                },
            }
        });
    });
</script>


<!--pic upload-->
<script type="text/javascript">
    $(function () {
        $('#file_upload_DevicePic').uploadifive({
            'formData': {
                'Id': $("#form_Id").attr("value"),
                'imagepath': $("#form_DevicePic").attr("value")
            },
            'uploadScript': '/devices/picUp',
            'fileTypeExts': '*.jpg; *.jpeg; *.png',
                'removeCompleted' : true,
                'fileSizeLimit':"10MB",
                'buttonClass':"btn-info",
                'multi': false,
            'onUploadComplete' : function(file, data) {
                var url_new = $.parseJSON(data).Data;
                $("#form_pic_DevicePic").attr("src", url_new);
                $("#form_DevicePic").attr("value", url_new.substring(0, url_new.indexOf("?time")));
            },
            'onUploadError': function (file, errorCode, errorMsg, errorString) {
                alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
            }
        });
    });
</script>




</body>
</html>